<%@ tag body-content="scriptless"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<%@ attribute name="roleEditable" required="true"%>
<%@ attribute name="title" required="true"%>
<%@ attribute name="name" required="true"%>
<%@ attribute name="path" required="true"%>
<%@ attribute name="type" required="true" %>
<%@ attribute name="allowNull" required="true"%>
<%@ attribute name="editable" required="true"%>
<%@ attribute name="className" required="true"%>
<%@ attribute name="validationType" required="true"%>
<%@ attribute name="maxLength" required="false"%>
<%@ attribute name="dateTimeIndex" required="false"%>
<%@ attribute name="maxPrecision" required="false"%>
<%@ attribute name="maxScale" required="false"%>
<%@ attribute name="tabindex" required="false"%>
<%@ attribute name="selectBox" required="false"%>

<spring:bind path="${path}">
<tr title="${title}">
  <c:choose>
  <c:when test="${editable}"><th style="padding-left:10px;width:150px;max-width:150px;min-width:150px;text-align:right;">${name}</th></c:when>
  <c:otherwise><th style="padding-left:10px;width:150px;max-width:150px;min-width:150px;text-align:right;">${name}:</th></c:otherwise>
  </c:choose>
  <td class="inputFieldsTd" align="left">

    <c:choose>
    <c:when test="${roleEditable}">
      <c:choose>
	    <c:when test="${editable}">
	      <c:choose>
	      <c:when test="${selectBox}">
	        <input type="hidden" id="${status.expression}_originalValue" name="${status.expression}_originalValue" value="${status.value}"/>
	        <select id="${status.expression}" name="${status.expression}" class="${className}" tabindex="${tabindex}"
	                onchange="fieldEdit('${status.expression}');afterFieldEdit('${title}','${validationType}','${status.expression}','${allowNull}',new Array());">
	          <jsp:doBody/>
	        </select><c:if test="${allowNull == 'false'}">&nbsp;*</c:if>
	      </c:when>
	      <c:otherwise>
		    <c:choose>
		    <c:when test="${type == 'text'}">
		      <input type="hidden" id="${status.expression}_originalValue" name="${status.expression}_originalValue" value="${status.value}"/>
		      <input type="text" id="${status.expression}" name="${status.expression}" value="${status.value}" class="${className}" maxlength="${maxLength}" tabindex="${tabindex}"
		             onkeyup="fieldEdit('${status.expression}');" onchange="afterFieldEdit('${title}','${validationType}','${status.expression}','${allowNull}',new Array(),'${maxPrecision}','${maxScale}');"/><c:if test="${allowNull == 'false'}">&nbsp;*</c:if>
		    </c:when>
		    <c:when test="${type == 'date'}">
		      <script type="text/javascript">$(function(){$.fx.speeds._default=10;$(parseIdForJQuery('${status.expression}')).datepicker({showOn:'button',buttonImage:'pages/images/themed/calendar.png',buttonText:'Select a date',buttonImageOnly:true,showAnim:'fadeIn',duration:'fast',dateFormat:'dd/mm/yy'});});</script>
		      <input type="hidden" id="${status.expression}_originalValue" name="${status.expression}_originalValue" value="${status.value}"/>
		      <input type="text" id="${status.expression}" name="${status.expression}" value="${status.value}" maxlength="10" class="dateTextField" tabindex="${tabindex}" onkeyup="fieldEdit('${status.expression}');" onchange="zeroTabDatePopulation('${status.expression}');afterFieldEdit('${title}', 'date', '${status.expression}', '${allowNull}', new Array());"/><c:if test="${allowNull == 'false'}">&nbsp;*</c:if>
		    </c:when>
		    <c:when test="${type == 'textArea'}">
		      <input type="hidden" id="${status.expression}_originalValue" name="${status.expression}_originalValue" value="${status.value}"/>
		      <textarea id="${status.expression}" name="${status.expression}" rows="5" cols="30" class="textAreaField" tabindex="${tabindex}" onkeydown="textAreaCounter(this,'${maxLength}');" onkeyup="fieldEdit('${status.expression}');textAreaCounter(this, '${maxLength}');" onchange="afterFieldEdit('${title}', 'string', '${status.expression}', '${allowNull}', new Array());">${status.value}</textarea><c:if test="${allowNull == 'false'}">&nbsp;*</c:if>
		      </td>
		    </tr>
		    <tr>
		      <td colspan="2" align="center"><label id="${status.expression}_remainingCharacters" style="align:center"></label>
		    </c:when>
		    </c:choose>
	      </c:otherwise>
	      </c:choose>
	    </c:when>
	    <c:otherwise>
	      ${status.value}
	      <input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}" class="${className}"/>
	    </c:otherwise>
	  </c:choose>
    </c:when>
    <c:otherwise>
      ${status.value}
	  <input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}" class="${className}"/>
    </c:otherwise>
    </c:choose>
  </td>
</tr>
<tr><td colspan="2" id="${status.expression}_errorField" class="errorText" style="visibility:hidden;display:none;"></td></tr>
</spring:bind>